package cn.ysym.dao;

import android.content.Context;

import java.util.ArrayList;
import java.util.List;

import cn.ysym.model.ShippingOrder;

public class ShippingOrderDao extends DaoBase {

    public ShippingOrderDao(Context context) {
        super(context);
    }

    public List<ShippingOrder> query(String filterStr) {
        List<ShippingOrder> ret = new ArrayList<>();
        List<String[]> objs;
        if (filterStr != null && filterStr.length() > 0)
            objs = this.query(Integer.MAX_VALUE, "select orderNo from shipping_order where orderNo like '%" + filterStr + "%'");
        else
            objs = this.query(Integer.MAX_VALUE, "select orderNo from shipping_order");
        for (String[] row : objs) {
            ShippingOrder shippingOrder = new ShippingOrder();
            shippingOrder.setOrderNo(row[0]);
            ret.add(shippingOrder);
        }
        return ret;
    }

    public void insert(ShippingOrder model) {
        this.execSql("insert into shipping_order(orderNo) values(?)", model.getOrderNo());
    }

    public void clearAll() {
        this.execSql("delete from shipping_order");
    }
}
